﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PortalBlock : BasicBlock
{
    public GameObject anotherPortal;
    public bool canTeleport = true;

    public override void BlockIn(GameObject player)
    {
        if (canTeleport && anotherPortal.GetComponent<PortalBlock>().canTeleport)
            //如果没有被传送过，传送到另一侧的门，并在离开传送门前无法再被传送
        {
            Debug.Log("in portal");
            base.BlockIn(player);
            player.transform.transform.position = anotherPortal.transform.position;
            canTeleport = false;
            anotherPortal.GetComponent<PortalBlock>().canTeleport = false;
        }
    }

    public override void BlockOut(GameObject player)
    {
        Debug.Log("out portal");
        base.BlockOut(player);
        canTeleport = true;
    }



}
